<!DOCTYPE HTML>
<html lang="en">
<head>
<title>Go - Go programming language | Docs4dev</title>
<meta charset="UTF-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<meta name="description" content="Go">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="HandheldFriendly" content="true">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta property="og:type" content="website">
<meta property="og:title" content="Go - Go programming language">
<meta property="og:url" content="https://www.docs4dev.com/docs/en/go/1.0/reference/">
<meta property="og:site_name" content="Docs4dev">
<meta property="og:locale" content="zh_CN">
<meta name="twitter:card" content="Go">
<meta name="generator" content="Docs4dev template engine">
<link rel="stylesheet" href="static/css/app.min.css">
<link rel="shortcut icon" href="https://www.docs4dev.com/static/images/favicon.ico" type="image/x-icon">
<script async="" src="static/js/js.js"></script>
<script async="" src="static/js/adsbygoogle.js" crossorigin="anonymous"></script>
<script>
    window.dataLayer = window.dataLayer || [];

    function gtag() {
      dataLayer.push(arguments);
    }

    gtag('js', new Date());
    gtag('config', 'UA-129571937-1');
  </script>
<link rel="amphtml" href="https://www.docs4dev.com/amp/docs/en/go/1.0/reference/index.html">

<link rel="stylesheet" href="static/css/style.css">
<script type="application/ld+json">{"name":null,"headline":"Go-Go programming language","inLanguage":"en-US","version":"1.0","image":"/static/icon/icon-go.svg","datePublished":"2021-05-21T14:10:21Z","dateCreated":"2021-05-21T14:10:21Z","dateModified":"2021-07-10T15:26:30Z","@context":"https://schema.org/","@type":"APIReference","abstract":"Go"}</script>
</head>
<body>
<div class="book with-summary">
<div class="book-summary">
<div class="logo">
<a href="javascript:window.open('https://www.docs4dev.com/docs/en/go/1.0/reference');" style="color: inherit;">
<img src="static/picture/icon-go.svg" style="width: 48px; height: 48px;" alt="Logo">
</a>
<b style="color: inherit; margin-left: 8px;">Go</b>
</div>
<div class="item">
<div>
<label for="version">版本</label>
<select id="version" onchange="onVersionChange(this)">
<option value="1.0" selected="selected">1.0</option>
</select>
</div>

</div>
<div class="item menus">
<a title="Table of Contents" style="margin-right: 8px;" href="#">
<i class="fa fa-chevron-left"></i>
<span style="margin-left: 2px;">返回目录</span>
</a>
</div>
<nav role="navigation" id="navigation">
<div id="toc"></div>
</nav>
</div>
<div class="book-body">
<div class="body-inner">
<header class="book-header">
<div class="dropdown pull-right js-toolbar-action">
<a class="btn toggle-dropdown" aria-label="Language" href="#">
<i class="fa fa-globe"></i>
</a>
<div class="dropdown-menu dropdown-left">
<div class="dropdown-caret"><span class="caret-outer"></span><span class="caret-inner"></span></div>
<div class="buttons">
<button class="button size-1" onclick="changeLang('zh_CN')">中文</button>
</div>
<div class="buttons">
<button class="button size-1" onclick="changeLang('en_US')">English</button>
</div>
</div>
</div>
<a class="btn pull-right js-toolbar-action non-mobile" aria-label="Sign up" href="register.html">
<i class="fa fa-sign-in"></i> <span>注册</span>
</a>
<a class="btn pull-right js-toolbar-action non-mobile" aria-label="Sign in" href="register.html">
<i class="fa fa-sign-in"></i>
<span>登录</span>
</a>
<a class="btn pull-left js-toolbar-action btn-summary" href="#"><i class="fa fa-align-justify"></i></a>
<div class="dropdown pull-left font-settings js-toolbar-action">
<a class="btn toggle-dropdown" aria-label="Font Settings" href="#">
<i class="fa fa-font"></i>
</a>
<div class="dropdown-menu dropdown-right">
<div class="dropdown-caret"><span class="caret-outer"></span><span class="caret-inner"></span></div>
<div class="buttons">
<button class="button size-2 font-reduce">A</button>
<button class="button size-2 font-enlarge">A</button>
</div>
<div class="buttons">
<button class="button size-2 family-serif">Serif</button>
<button class="button size-2 family-sans">Sans</button>
</div>
<div class="buttons">
<button class="button size-3 theme-white">White</button>
<button class="button size-3 theme-sepia">Sepia</button>
<button class="button size-3 theme-night">Night</button>
</div>
</div>
</div>
<a class="btn pull-left js-toolbar-action non-mobile" aria-label="Home" href="en.html">
<i class="fa fa-home"></i> <span>首页</span>
</a>
<a class="btn pull-left js-toolbar-action non-mobile" aria-label="Guide" href="javascript:window.open('https://www.javadoc.org/');">
<i class="fa fa-book"></i> <span>API Docs</span>
</a>
<a class="btn pull-left js-toolbar-action non-mobile" aria-label="Tools" href="index37.html">
<i class="fa fa-gears"></i> <span>工具</span>
</a>
<div class="dropdown pull-left js-toolbar-action mobile">
<a class="btn toggle-dropdown" aria-label="Language" href="#">
<i class="fa fa-chevron-down"></i>
</a>
<div class="dropdown-menu dropdown-right">
<div class="dropdown-caret"><span class="caret-outer"></span><span class="caret-inner"></span></div>
<div class="buttons">
<a class="button size-1" aria-label="Home" href="en.html">
<i class="fa fa-home"></i> <span>首页</span>
</a>
</div>
<div class="buttons">
<a class="button size-1" aria-label="Guide" href="javascript:window.open('https://www.javadoc.org/');">
<i class="fa fa-book"></i> <span>API Docs</span>
</a>
</div>
<div class="buttons">
<a class="button size-1" aria-label="Tools" href="index37.html">
<i class="fa fa-gears"></i> <span>工具</span>
</a>
</div>
</div>
</div>
<div id="autocomplete" class="pull-right"></div>
<span id="toolbar-title"></span>
</header>
<div class="page-wrapper" tabindex="-1" role="main">
<div class="page-inner">
<section class="normal markdown-section">
<div id="content">
<h1>Go programming language</h1>
<div><ins class="adsbygoogle" style="display:block; text-align:center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-6108808167664152" data-ad-slot="6964403648"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script></div>
<div><div id="nav"></div>
<div class="HomeContainer">
<section class="HomeSection Hero">
<p> Go is an open source programming language that makes it easy to build <strong>simple</strong>, <strong>reliable</strong>, and <strong>efficient</strong> software. </p>
<ul>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/go/1.0/reference/doc.html');">Documents</a></li>
<li><a href="javascript:window.open('https://www.docs4dev.com/docs/en/go/1.0/reference/pkg.html');">Packages</a></li>
<li><a href="javascript:window.open('https://golang.org/project/');" target="_blank" rel="noopener noreferrer">The Project <i class="fa fa-external-link"></i></a></li>
<li><a href="javascript:window.open('https://golang.org/help');" target="_blank" rel="noopener noreferrer">Help <i class="fa fa-external-link"></i></a></li>
<li><a href="javascript:window.open('https://golang.org/blog/');" target="_blank" rel="noopener noreferrer">Blog <i class="fa fa-external-link"></i></a></li>
<li><a href="javascript:window.open('https://play.golang.org/');" target="_blank" rel="noopener noreferrer">Play <i class="fa fa-external-link"></i></a></li>
</ul>
<a href="javascript:window.open('https://www.docs4dev.com/docs/en/go/1.0/reference/dl.html');" class="Button Button--big HeroDownloadButton"> <img class="HeroDownloadButton-image" src="https://www.docs4dev.com/images/go/1.0/cloud-download.svg" alt=""> Download Go </a>
<p class="Hero-description"> Binary distributions available for<br> Linux, macOS, Windows, and more. </p>
</section>
<section class="HomeSection Playground">
<div class="Playground-headerContainer">
<h2 class="HomeSection-header" id="Try-Go">Try Go</h2>
<a class="Playground-popout js-playgroundShareEl">Open in Playground</a>
</div>
<div class="Playground-inputContainer">
<textarea class="Playground-input js-playgroundCodeEl" spellcheck="false" aria-label="Try Go">// You can edit this code!
// Click here and start typing.
package main

import "fmt"

func main() {
	fmt.Println("Hello, 世界")
}
</textarea>
</div>
<div class="Playground-outputContainer js-playgroundOutputEl">
<pre class="Playground-output notranslate"></pre>
</div>
<div class="Playground-controls">
<select class="Playground-selectExample js-playgroundToysEl" aria-label="Code examples"> <option value="hello.go">Hello, World!</option> <option value="life.go">Conway's Game of Life</option> <option value="fib.go">Fibonacci Closure</option> <option value="peano.go">Peano Integers</option> <option value="pi.go">Concurrent pi</option> <option value="sieve.go">Concurrent Prime Sieve</option> <option value="solitaire.go">Peg Solitaire Solver</option> <option value="tree.go">Tree Comparison</option> </select>
<div class="Playground-buttons">
<button class="Button Button--primary js-playgroundRunEl" title="Run this code [shift-enter]">Run</button>
<div class="Playground-secondaryButtons">
<button class="Button js-playgroundShareEl" title="Share this code">Share</button>
<a class="Button tour" href="javascript:window.open('https://tour.golang.org/');" title="Playground Go from your browser" target="_blank" rel="noopener noreferrer">Tour <i class="fa fa-external-link"></i></a>
</div>
</div>
</div>
</section>
<section class="HomeSection Blog js-blogContainerEl">
<h2 class="HomeSection-header" id="Featured-articles">Featured articles</h2>
<div class="Blog-footer js-blogFooterEl">
<a class="Button Button--primary" href="javascript:window.open('https://blog.golang.org/');" target="_blank" rel="noopener noreferrer">Read more &gt; <i class="fa fa-external-link"></i></a>
</div>
</section>
<section class="HomeSection">
<h2 class="HomeSection-header" id="Featured-video">Featured video</h2>
<div class="js-videoContainer" style="--aspect-ratio-padding: 58.07%;">
<a href="">https://www.youtube.com/embed/rFejpH_tAHM</a>
</div>
</section>
</div></div>
</div>
</section>
<div class="right-sidebar">
<div class="affix"><ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-6108808167664152" data-ad-slot="3102929424" data-ad-format="auto" data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script></div>
</div>
</div>
<div class="ft">
<a href="#toolbar-title" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a>
<footer class="footer">
<div class="footer__container--normal">
<img alt="扫码关注公众号" title="扫码关注公众号" src="static/picture/qr-code.png" width="170" height="170">
<div class="footer__description--normal">
<p class="paragraph footer__author--normal">Docs4dev<sup class="super">&#xAE;</sup>
</p>
<p class="paragraph footer__quote&#45;&#45;normal">
如果你在使用过程中遇到任何问题，可以在 <a href="javascript:window.open('https://github.com/docs4dev/docs4dev-issues');" target="_blank" rel="noopener noreferrer">这里<i class="fa fa-external-link"></i></a> 提issue。
</p>
<div class="footer__main--normal">
<p class="paragraph footer__main__paragraph--normal copyright" style="color: #666 !important;">
<a href="javascript:window.open('https://beian.miit.gov.cn/');">
蜀ICP备14021783号-6
</a>
</p>
<p class="paragraph footer__main__paragraph--normal copyright" style="color: #666 !important;">
Copyright &#xA9; Docs4dev all
right reserved, powered by <a href="index2.html" target="_blank">Docs4dev</a></p>
</div>
</div>
</div>
<div class="box__issues">
</div>
</footer>
</div>
</div>
</div>
</div>
</div>
<script src="static/js/download.js"></script><script src="static/js/godocs.js"></script>
<script>
  var hasToc = true;
  /*  var downloadable = /!*false*!/ false;
    var editable = /!*false*!/ false;
    var code = /!*"go"*!/ false;
    var version = /!*"1.0"*!/ false;
    var type = /!*"reference"*!/ false;
    var lang = /!*"en"*!/ 'en';
    //edit link
    require(["gitbook", "jQuery"], function (gitbook, $) {
      gitbook.events.bind('start', function (e, config) {
        // Add edit toolbar to left
        var chapterId = /!*16922*!/ 0;
        if (downloadable) {
          gitbook.toolbar.createButton({
            icon: 'fa fa-download',
            text: '下载',
            onClick: function () {
              window.open('/download?code=' + code + '&version=' + version + '&type=' + type + '&lang=' + lang);
            }
          });
        }
        if (editable) {
          gitbook.toolbar.createButton({
            icon: 'fa fa-edit',
            text: '编辑此页',
            onClick: function () {
              window.open('/docs/edit?chapterId=' + chapterId + '&lang=' + lang);
            }
          });
        }
      });
    });*/
</script>
<script>
    var code = "go";
    var lang = "en";
  </script>

<script src="static/js/autocomplete-js.js"></script>
<script src="static/js/app.min.js"></script>
<script src="static/js/search.min.js"></script>
</body>
</html>
